home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F17452_ToTheLifeBoats.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-09-24  |  1.4 KB  |  40 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
  4. <!-- Order XML nodes on a precedence -->
  5.  
  6. <!-- define a precedence order variable -->
  7. <xsl:variable name="lifeboat-precedence" select="'|*|Man|Boy|Woman|Girl'"/>
  8. <!-- Note: the precedence is specified in reverse order! -->
  9.  
  10. <xsl:template match="/">
  11.     <html>
  12.         <head>
  13.             <title>Women and Children to the life boats first!</title>
  14.         </head>
  15.         <body>
  16.             <h3>Women and Children to the life boats first!</h3>
  17.             <table border="1">
  18.                 <tr>
  19.                     <th>Priority</th>
  20.                     <th>Passenger name</th>
  21.                     <th>Age/Gender</th>
  22.                     <th>No.</th>
  23.                 </tr>
  24.                 <xsl:apply-templates select="passengers/passenger">
  25.                     <xsl:sort select="string-length(substring-before($lifeboat-precedence,concat('|',@age_gender)))" data-type="number" order="descending"/>
  26.                 </xsl:apply-templates>
  27.             </table>
  28.         </body>
  29.     </html>
  30. </xsl:template>
  31.  
  32. <xsl:template match="passenger">
  33.     <tr>
  34.         <td align="right"><xsl:value-of select="string-length(substring-before($lifeboat-precedence,concat('|',@age_gender)))"/></td>
  35.         <td><xsl:value-of select="."/></td>
  36.         <td><xsl:value-of select="@age_gender"/></td>
  37.         <td align="right"><xsl:value-of select="count(preceding-sibling::passenger)+1"/></td>
  38.     </tr>
  39. </xsl:template>
  40. </xsl:stylesheet>